package org.smartercontext.contextmger.fixedgatherers;

import org.smartercontext.contextmger.ciphermodule.CipherAES;
import org.smartercontext.contextmger.contextsphere.ContextSphereController;

public class ExternalLogin implements IExternalLogin {

	public ExternalLogin(){
		
	}
	
	@Override
	public boolean login(String usernameG, String passwordG){
		
			
			String userEncrypted = usernameG;
			String passEncrypted = passwordG;
			
			CipherAES caes=new CipherAES();
			
			String userDecrypted = caes.encrypt_decrypt(userEncrypted, false);
			String passDecrypted = caes.encrypt_decrypt(passEncrypted, false);
			
			String username = caes.hexToString(userDecrypted);
			String password = caes.hexToString(passDecrypted);
						
			ContextSphereController csc = new ContextSphereController();
			boolean exists = csc.validateUser(username, password);
			
			return exists;
			
	}
}
